#ifndef _TYPE_H_
#define _TYPE_H_

#define SERIAL "/dev/ttyUSB0"
#define FREQ_NANOSECS 6
#define FIRST_RUN 1
#define MAX_THREAD 3
#define NET_PORT 8888
#define MSG_SIZE 1024
#define OFFLINE_TIMEOUT 600l
#define OFFLINE 0
#define ONLINE 1

enum {
    UNKNOWN = 0,
    MASTER = 1,
    STANDBY = 2

};

enum {
    UART_HEART_BEAT = 0X10,
    NET_HEART_BEAT = 0X20
};

typedef struct
{
    unsigned char type;
    unsigned char mode;
    unsigned short arg;
    char data[];

} msg_t;

typedef struct
{
    int thread_count;

    int myself_slot_id;
    int role;

    char *p_serial;	
    int serial_fd;
	
    int net_fd;
    int net_port;

    bool slot_online;
    int online;
	
    int serial_status;
    int net_status;
	
    long heartbeat;
    unsigned long timer_first;
    unsigned long timer_interval;
    char role_arry[16];
    char net_ip[16];
} standby_t;

enum {
    HANDSHAKE   = 0xf1,
	REQEST      = 0xf2,
    RESPONE     = 0xf3,
    ACK         = 0Xfb,
    HEARTBEAT   = 0Xfc,
    RELEASE     = 0Xfe,
    REFRESH     = 0xff,
};

enum {
    INVALID = -1,

};


#endif
